package cn.sam.servlet;


import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;

//继承Tomcat中的HttpServlet
@WebServlet("/hello")
public class HelloServlet implements Servlet {

    public void init(ServletConfig servletConfig) throws ServletException {
        System.out.println("在客户端第一次访问时会执行此方法");
    }

    public ServletConfig getServletConfig() {
        return null;
    }

    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        System.out.println("浏览器每次访问都会执行这个方法");
        System.out.println();
    }

    public String getServletInfo() {
        return null;
    }

    public void destroy() {
        System.out.println("当服务器关闭时会执行这个方法");
    }
}
